package myDemo.bobo.game.wuziqiAiMy.demo;

import java.awt.Image;
import java.awt.Toolkit;
import java.util.ArrayList;
import java.util.List;

import myDemo.bobo.game.wuziqiAiMy.IChessboard;
import myDemo.bobo.game.wuziqiAiMy.Point;

public class ChessBoardImpl implements IChessboard {
	private int MARGIN = 30;// 边距
	private int GRID_SPAN = 35;// 网格间距
	private int ROWS = 15;// 棋盘行数
	private int COLS = 15;// 棋盘列数
	private boolean isBlack = true;// 默认开始是黑棋先
	private boolean gameOver = false;// 游戏是否结束
	private int chessCount;// 当前棋盘棋子的个数
	private int xIndex, yIndex;// 当前刚下棋子的索引
	List<Point> readylist = new ArrayList<Point>();//已经被下过的棋子

	@Override
	public int getMaxX() {
		return COLS;
	}

	@Override
	public int getMaxY() {
		return ROWS;
	}

	@Override
	public List<Point> getFreePoints() {
		List<Point> remaidlist = new ArrayList<Point>();//已经被下过的棋子
		for (int i = 0; i < ROWS; i++) {
			for (int j = 0; j < COLS; j++) {
				Point p= new Point(i, j);
				if(!readylist.contains(p)){
					remaidlist.add(p);
				}
			}
		}
		return remaidlist;
	}
	
	@Override
	public int getMargin() {
		return MARGIN;
	}

	@Override
	public int getGridSpan() {
		return GRID_SPAN;
	}

	@Override
	public boolean isBlackFirst() {
		return isBlack;
	}

	@Override
	public boolean isGameOver() {
		return gameOver;
	}

	@Override
	public Image getImg() {
		return Toolkit.getDefaultToolkit().getImage("board.jpg");
	}

	@Override
	public Image getShadows() {
		return Toolkit.getDefaultToolkit().getImage("shadows.jpg");
	}

	@Override
	public boolean removePoint(Point t) {
//		list.remove(t);
		readylist.add(t);
		return true;
	}

	@Override
	public void setGameOver() {
		gameOver=true;
	}

	@Override
	public boolean reset() {
		readylist.clear();
		isBlack=true;
		gameOver=false;
		return true;
	}

	@Override
	public boolean setBlack(boolean b) {
		isBlack=b;
		return true;
	}

	@Override
	public List<Point> getReadyPlayPoints() {
		return readylist;
	}
	

}
